Skip to content

fix: create storageState directory if it does not exist#1522

Open
Flare576 wants to merge 1 commit intoVersent:masterfrom
Flare576:fix/browser-storage-state-mkdir
Open

fix: create storageState directory if it does not exist#1522
Flare576 wants to merge 1 commit intoVersent:masterfrom
Flare576:fix/browser-storage-state-mkdir

Conversation

@Flare576
Copy link
Copy Markdown

Problem

The Browser provider saves session state to ~/.aws/saml2aws/storageState.json after each login (introduced in #1267), but never creates the ~/.aws/saml2aws/ directory first.

If the directory doesn't exist, context.StorageState() fails silently — the error is logged at Info level but otherwise swallowed — and the session is never persisted. This means every login requires full re-authentication including MFA, completely defeating the purpose of the storageState feature.

Fix

Call os.MkdirAll on the directory before attempting to save state. If directory creation fails (e.g. permissions), log a warning and continue rather than hard-failing the auth flow.

Also fixes a pre-existing typo in a comment: broswerbrowser.

How to reproduce the original bug

  1. Fresh machine (or manually rm -rf ~/.aws/saml2aws/)
  2. Run saml2aws login with Browser provider
  3. Complete authentication including MFA
  4. Check ~/.aws/saml2aws/ — directory does not exist, state was never saved
  5. Run saml2aws login again — MFA is required again despite just authenticating

The Browser provider saves session state to ~/.aws/saml2aws/storageState.json
after each login, but never creates the ~/.aws/saml2aws/ directory. If the
directory does not exist, context.StorageState() silently fails and the session
is never persisted — meaning every login requires full re-authentication
including MFA, defeating the purpose of the storageState feature introduced
in Versent#1267.

Fix: call os.MkdirAll on the directory before attempting to save.

Also fixes a pre-existing typo: 'broswer' -> 'browser' in comment.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant